package com.small.sentinel.slots;

import com.small.sentinel.Context;
import com.small.sentinel.node.DefaultNode;
import com.small.sentinel.slotchain.ResourceWrapper;

public class SentinelResource {

    private Context context;

    private ResourceWrapper resourceWrapper;

    private DefaultNode defaultNode;

    private Object[] args;

    private int count;

    public SentinelResource() {
    }

    public static class SentinelResourceBuilder{

        private Context context;

        private ResourceWrapper resourceWrapper;

        private DefaultNode defaultNode;

        private Object[] args;

        private int count;

        public SentinelResourceBuilder(Context context, ResourceWrapper resourceWrapper) {
            this.context = context;
            this.resourceWrapper = resourceWrapper;
            this.count = 1;
        }

        public SentinelResourceBuilder appendDefaultNode(DefaultNode defaultNode){
            this.defaultNode = defaultNode;
            return this;
        }

        public SentinelResourceBuilder appendArgs(Object[] args){
            this.args = args;
            return this;
        }

        public SentinelResourceBuilder appendCount(int count){
            this.count = count;
            return this;
        }

        public SentinelResource builder(){
            SentinelResource resource = new SentinelResource();
            resource.setContext(this.context);
            resource.setResourceWrapper(this.resourceWrapper);
            resource.setDefaultNode(this.defaultNode);
            resource.setArgs(this.args);
            resource.setCount(this.count);
            return resource;
        }
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public ResourceWrapper getResourceWrapper() {
        return resourceWrapper;
    }

    public void setResourceWrapper(ResourceWrapper resourceWrapper) {
        this.resourceWrapper = resourceWrapper;
    }

    public DefaultNode getDefaultNode() {
        return defaultNode;
    }

    public void setDefaultNode(DefaultNode defaultNode) {
        this.defaultNode = defaultNode;
    }

    public Object[] getArgs() {
        return args;
    }

    public void setArgs(Object[] args) {
        this.args = args;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
